﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SqlCon;

namespace yfxt
{
    public partial class xt_yfqh : Form
    {
        public xt_yfqh()
        {
            InitializeComponent();
        }
        //mainform form = new mainform(ygxm, ygbh);
        #region  药房信息获取
        private void xt_yfqh_Load(object sender, EventArgs e)
        {
            string constr;            
            DataTable dt = new DataTable();
            constr="select yfsb ,yfmc from yf_yflb";
            dt.Load(SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction,CommandType.Text,constr,null));
            dataGridView1.Columns[0].DataPropertyName = dt.Columns[0].ToString();
            dataGridView1.Columns[1].DataPropertyName = dt.Columns[1].ToString();
            dataGridView1.DataSource = dt;                       
        }
        #endregion
        

        //private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        //{
        //    DataGridViewCheckBoxCell checkbox = (DataGridViewCheckBoxCell)this.dataGridView1.Rows[e.RowIndex].Cells[2];
        //    checkbox.Value = 1;
        //    if (e.ColumnIndex == 2 && e.RowIndex != -1)
        //    {
        //        if ((bool)dataGridView1.Rows[e.RowIndex].Cells[2].EditedFormattedValue == true)
        //        {
        //            dataGridView1.Rows[e.RowIndex].Cells[2].Value = false;
        //        }
        //        else
        //        {
        //            dataGridView1.Rows[e.RowIndex].Cells[2].Value = true;
        //        }
        //    }
            
        //}

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }

        #region 药房切换确认
        private void button1_Click(object sender, EventArgs e)
        {
            int ind=0;
            string yfbh;
            ind = dataGridView1.CurrentCell.RowIndex;
            yfbh = dataGridView1.Rows[ind].Cells["Column1"].Value.ToString().Trim();
            mainform.yfmc = dataGridView1.Rows[ind].Cells["Column2"].Value.ToString().Trim();
            mainform.yfsb = int.Parse(yfbh);
            this.Close();

        }
        #endregion




    }
}
